<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'form',
    'enableClientValidation' => true,
    'clientOptions' => array(
        'validateOnSubmit' => true,
    ),
        ));
?>
<a class="login-link" onclick="$('#login-form').fadeToggle();" href="#">Đăng nhập <img src="images/show-down.png" /></a>
<div id="login-form" style='<?php if($visible == false) echo 'display:none;'; ?>'>
    <img src="images/baloon-arrow.png" style="position: relative; top: -28px; left: -3px;" />
    <?php
        echo $form->textField($model, 'username', array(
            'class' => ($model->getError('username') == 'Username cannot be blank.') ? 'input-error' : '',
            'placeholder' => ($model->getError('username') == 'Username cannot be blank.') ? $model->getError('username') : 'Tên đăng nhập')); 
    ?>
    <br />
        <?php echo $form->passwordField($model, 'password', array(
            'class' => ($model->getError('password') != 'Password cannot be blank.') ? '' : 'input-error',
            'placeholder' => ($model->getError('password') != 'Password cannot be blank.') ? 'Mật khẩu' : $model->getError('password')));
        ?>
    
    <span class="error" style="margin-top: -5px;margin-bottom: 5px;display:block;">&nbsp;
        <?php
        if($model->getError('password') == "Incorrect username or password.")
            echo $model->getError('password');
    ?>
        
    </span>
    <div id="login-button-side">
        <?php echo $form->checkBox($model, 'rememberMe'); ?>
        <?php echo $form->label($model, 'rememberMe'); ?>
<?php echo CHtml::ajaxSubmitButton('Đăng nhập', Yii::app()->createUrl('site/ajaxLogin'), array('update' => '#form'), array('class' => 'btn right')); ?>
    </div>
    <div id="login-link-side">
        <a href="#" class="forgetLink">Quên mật khẩu?</a>
        <a href="#" class="regLink">Đăng kí mới!</a>
    </div>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
